package cn.taofuxn.sale.bean;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import javax.persistence.*;
import java.util.Date;

/**
 * ProjectName : GeekSaleSystem
 * PackageName : cn.taofuxn.sale.bean
 * Created by Wong
 * Date: 2018/3/15
 * Time: 16:11
 */
@Table(name = "tb_sale_goods")
@Entity
public class TbGoods {
	
	@Id
	@GenericGenerator(name = "IdGenerater",strategy = "cn.taofuxn.sale.util.IdGenerater" ,parameters = {@Parameter(name = "prefix",value = "goods")})
	@GeneratedValue(generator = "IdGenerater")
	private String id;
	private String name;
	/**
	 * 供应商
	 */
	@JoinColumn(name = "producerId")
	@OneToOne
	private TbProducer provider;
	/**
	 * 商品代销价格
	 */
	private float providerPrice;
	/**
	 * 销售单价
	 */
	private float price;
	
	/**
	 * 商品折扣价
	 */
	private float discountPrice;
	
	/**
	 * 商品来自的平台
	 */
	private PlatformType platform;
	
	/**
	 * 创建时间
	 */
	@CreationTimestamp
	@Temporal(TemporalType.TIMESTAMP)
	@JsonFormat(pattern = "yyyy-MM-dd hh:mm")
	private Date createTime;
	
	public Date getCreateTime() {
		return createTime;
	}
	
	public void setCreateTime(final Date vCreateTime) {
		createTime = vCreateTime;
	}
	
	public float getProviderPrice() {
		return providerPrice;
	}
	
	public void setProviderPrice(final float vProviderPrice) {
		providerPrice = vProviderPrice;
	}
	
	public float getPrice() {
		return price;
	}
	
	public void setPrice(final float vPrice) {
		price = vPrice;
	}
	
	public String getId() {
		return id;
	}
	
	public void setId(final String vId) {
		id = vId;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(final String vName) {
		name = vName;
	}
	
	public TbProducer getProvider() {
		return provider;
	}
	
	public void setProvider(final TbProducer vProvider) {
		provider = vProvider;
	}
	
	public float getDiscountPrice() {
		return discountPrice;
	}
	
	public void setDiscountPrice(final float vDiscountPrice) {
		discountPrice = vDiscountPrice;
	}
	
	public PlatformType getPlatform() {
		return platform;
	}
	
	public void setPlatform(final PlatformType vPlatform) {
		platform = vPlatform;
	}
	
	public enum PlatformType{
		ME("self",(byte) 0),
		AL("Alibaba",(byte) 1);
		
		private String name;
		private byte type;
		
		PlatformType(final String vName, final byte vType) {
			name = vName;
			type = vType;
		}
	}
}
